var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/goods', function(req, res){
  console.log(req.query);

  res.send('商品列表内容');
});

router.get('/product/:id', (req, res)=>{
  console.log(req.params);

  let id = req.params.id;
  if(id === '1'){
    res.render('product1');
  }else if(id === '2'){
    res.render('product2');
  }else{
    res.end();
  }
});

module.exports = router;
